﻿
@{
    ViewData["Title"] = "访问IP限制";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div white-bg">
    <div class="ibox-content">
        <form class="form-horizontal m" id="form" autocomplete="off">
            <input type="hidden" name="id" id="id" value="">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">起始IP地址：</label>
                <div class="col-sm-4">
                    <input type="text" name="start_ip" id="start_ip" value="" class="form-control" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">结束IP地址：</label>
                <div class="col-sm-4">
                    <input type="text" name="end_ip" id="end_ip" value="" class="form-control" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">启用状态</label>
                <div class="col-sm-4">
                    <div class="checkbox checkbox-success checkbox-inline">
                        <input type="checkbox" id="limit_enable" name="limit_enable" value="1" checked="">
                        <label for="enable">启用</label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-4">
                    <textarea name="remark" id="remark" cols="60" rows="4"></textarea>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="footerbar">
                <div class="col-sm-12 col-sm-offset-4">
                    <button class="btn btn-primary" type="submit">
                        <i class="fa fa-check"></i>
                        保存
                    </button>
                    <button class="btn btn-danger" type="button" onclick="cancel()">
                        <i class="fa fa-reply-all"></i>关闭
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
@section scripts{
    <script>

        $(function () {
            var id = jutils.getQueryParam("id");
            $("#id").val(id);

            $('#form').validator({
                stopOnError: false,
                timely: 2,
                theme: "yellow_right",
                valid: function (form) {
                    jutils.ajaxPost('/siteset/ipmanager/Save', $(form).serialize(), function (res) {
                        if (res.status) {
                            jutils.success("保存成功");
                            cancel();
                        }
                    });
                   
                }
            });

            loadData();
        });


        function loadData() {
            var id = $("#id").val();
            jutils.ajaxGet('/siteset/ipmanager/getmodel', { id: id }, function (res) {
                if (id !== '0') {
                    $('#form').initFormData(res.data.model);
                }

            });


        }


        function cancel() {
            jutils.closeDialog();
        }
    </script>
}
